home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / QuickDraw GX / QuickDraw GX Info / QuickDraw GX Interfaces / Interfaces & Libraries / graphics libraries / framing library.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-30  |  1.8 KB  |  43 lines  |  [TEXT/MPS ]

  1. /* graphics libraries:
  2.     Better gxShape framing routines
  3.     by Cary Clark, Georgiann Delaney, Michael Fairman, Pablo Fernicola, Dave Good, Robert Johnson, Keith McGreggor, Oliver Steele, David Van Brink, Chris Yerga
  4.     Copyright 1987 - 1993 Apple Computer, Inc.  All rights reserved.    */
  5.  
  6. #include "graphics libraries.h"
  7.  
  8. void OutsetShape(gxShape source, Fixed outset)
  9. {
  10.     gxShape temp = GXCopyToShape(nil, source);
  11.     boolean framed = GXGetShapeFill(source) < gxEvenOddFill;
  12.     GXSetShapeFill(source, gxWindingFill);
  13.     GXSetShapeFill(temp, gxClosedFrameFill);
  14.     GXSetShapeStyleAttributes(temp, gxCenterFrameStyle);
  15.     GXSetShapePen(temp, (outset < 0 ? -outset : outset) << 1);
  16.     GXPrimitiveShape(temp);
  17.     if (outset > 0)                         /* if we are outsetting */
  18.         GXUnionShape(source, temp);
  19.     else if (outset < 0)                        /* if we are insetting */
  20.         GXDifferenceShape(source, temp);
  21.     if (framed)
  22.         GXSetShapeFill(source, gxClosedFrameFill);
  23.     GXDisposeShape(temp);
  24. }
  25.  
  26. void FrameShape(gxShape source, Fixed outset)
  27. {
  28.     gxShape temp = GXCopyToShape(nil, source);
  29.     gxShapeFill originalFill = GXGetShapeFill(source);
  30.     GXSetShapeFill(temp, gxWindingFill);
  31.     GXSetShapeFill(source, gxClosedFrameFill);
  32.     GXSetShapeStyleAttributes(source, gxCenterFrameStyle);
  33.     GXSetShapePen(source, (outset < 0 ? -outset : outset) << 1);
  34.     GXPrimitiveShape(source);
  35.     if (outset > 0)                         /* if we are outside framing */
  36.         GXDifferenceShape(source, temp);
  37.     else if (outset < 0)                        /* if we are inside framing */
  38.         GXIntersectShape(source, temp);
  39.     else                                    /* the outset is 0 */
  40.         GXSetShapeFill(source, gxClosedFrameFill);
  41.     GXDisposeShape(temp);
  42. }
  43.